package com.gmail.avereshchaga.db.service;

import com.gmail.avereshchaga.db.dao.IInvoiceItemsDAO;
import com.gmail.avereshchaga.db.entity.IInvoiceItems;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author <a href="mailto:avereshchaga@gmail.com">Vereshchaga Alexey</a>
 */
@Service
public class InvoiceItemsServiceImpl implements IInvoiceItemsService {

    @Autowired
    IInvoiceItemsDAO invoiceItemsDAO;

    @Transactional
    @Override
    public List<IInvoiceItems> findByInvoiceId(Long invoiceId) {
        return invoiceItemsDAO.findByInvoiceId(invoiceId);
    }

    @Transactional
    @Override
    public IInvoiceItems createInvoiceItems(IInvoiceItems invoiceItem) {
        invoiceItemsDAO.createInvoiceItems(invoiceItem);
        return invoiceItem;
    }

    @Transactional
    @Override
    public IInvoiceItems updateInvoiceItems(IInvoiceItems invoiceItem) {
        invoiceItemsDAO.updateInvoiceItems(invoiceItem);
        return invoiceItem;
    }

    @Transactional
    @Override
    public void deleteInvoiceItems(IInvoiceItems invoiceItem) {
        Long id = invoiceItem.getId();
        invoiceItemsDAO.deleteInvoiceItems(id);
    }
}
